package StudyCode.summary.myfile;

import java.io.File;
import java.io.IOException;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class FileInsideDirectory {
	public static void main(String[] argv) throws Exception {
		File file = new File("E:/Copy/test.txt");
		File dir = new File("E://Copy");
		System.out.println("文件 " + file + "是否在 " + dir + " 中？" + isLocatedInside(file, dir));
	}


	private static boolean isLocatedInside(File file, File dir) throws IOException {
		return file.getCanonicalPath().startsWith(dir.getCanonicalPath());
	}
}
